
import { DOMParser } from 'xmldom';

export default class BpmnUtil {
  static parseXML = (XMLStr) => {
    const xmlDoc = new DOMParser().parseFromString(XMLStr, 'text/xml');
    const taskNodes = xmlDoc.getElementsByTagName('bpmn2:task');
    return Array.from(taskNodes)
      .map((item) => Array.from(item.attributes)
        .reduce((a, v) => ({ ...a, [v.nodeName]: v.nodeValue }), {}));
  }
}
